#ifndef XW_GAME_H
#define XW_GAME_H

static const int MAXN = 50;

// call backs
typedef void (*FunOnRefresh)(int nRow, int nCol);
typedef void (*FunOnLose)();
typedef void (*FunOnWin)();
typedef void (*FunOnFlagsChange)(int flagNumber);
typedef void (*FunOnGameStart)();
typedef void (*FunOnGameInit)();
typedef void (*FunOnGameTimer)();

typedef struct tagGameCallbacks
{
    FunOnRefresh       onRefresher;
    FunOnLose          onLose;
    FunOnWin           onWin;
    FunOnFlagsChange   onFlagsChange;
    FunOnGameStart     onGameStart;
    FunOnGameInit      onGameInit;
    FunOnGameTimer     onGameTimer;
} GameCallbacks;

// api

void InitializeGame(int nRow, int nCol, int nMines, GameCallbacks callbacks);
void StartGame();
void StopGame();

void SetSize(int nRow, int nCol);
int GetRow();
int GetCol();

void SetMines(int nMines);
int GetMines();
int GetFlags();

char GetCell(int nRow, int nCol);
int GetMask(int nRow, int nCol);

int IsGameStarted();
int IsGameOver();
int IsGameDead(); // GameOver and NotAllCleared
int IsAllCleared();

void DoFlag(int nRow, int nCol); // Flag
void DoOpen(int nRow, int nCol); // Open
void DoDetect(int nRow, int nCol); // Detect
void DoMask(int nRow, int nCol, int nDim); // Mask
void DoMaskRelease(); // Release Mask

#endif // XW_GAME_H
